/*
 * @(#)MaintUserGroupForm.java
 *
 * Copyright (c) 2003 DCIVision Ltd
 * All rights reserved.
 *
 * This software is the confidential and proprietary information of DCIVision
 * Ltd ("Confidential Information").  You shall not disclose such Confidential
 * Information and shall use it only in accordance with the terms of the license
 * agreement you entered into with DCIVision Ltd.
 */
package com.dcivision.user.web;

import javax.servlet.http.HttpServletRequest;

import org.apache.struts.action.ActionErrors;
import org.apache.struts.action.ActionMapping;

import com.dcivision.framework.ApplicationException;
import com.dcivision.framework.TextUtility;
import com.dcivision.framework.bean.AbstractBaseObject;
import com.dcivision.framework.web.AbstractActionForm;
import com.dcivision.user.bean.UserGroup;

/**
  MaintUserGroupForm.java

  This class is the for web form purpose.

  @author      Rollo Chan
  @company     DCIVision Limited
  @creation date   17/07/2003
  @version     $Revision: 1.5 $
*/

public class MaintUserGroupForm extends AbstractActionForm {

  public static final String REVISION = "$Revision: 1.5 $";

  private String ownerUserRecordID = null;
  private String groupType = null;
  private String groupName = null;
  private String groupDesc = null;

  /** Holds value of property userRoles. */
  private String[] userRoles = null;

  public MaintUserGroupForm() {
    super();
  }

  public String getOwnerUserRecordID() {
    return(this.ownerUserRecordID);
  }

  public void setOwnerUserRecordID(String ownerUserRecordID) {
    this.ownerUserRecordID = ownerUserRecordID;
  }

  public String getGroupType() {
    return(this.groupType);
  }

  public void setGroupType(String groupType) {
    this.groupType = groupType;
  }

  public String getGroupName() {
    return(this.groupName);
  }

  public void setGroupName(String groupName) {
    this.groupName = groupName;
  }

  public String getGroupDesc() {
    return(this.groupDesc);
  }

  public void setGroupDesc(String groupDesc) {
    this.groupDesc = groupDesc;
  }

  public String[] getUserRoles() {
    return(this.userRoles);
  }

  public void setUserRoles(String[] userRoles) {
    this.userRoles = userRoles;
  }

  public ActionErrors validate(ActionMapping mapping, HttpServletRequest request) {
    return super.validate(mapping, request);
  }

  public void reset(ActionMapping mapping, HttpServletRequest request) {
    super.reset(mapping, request);
    this.setID(null);
    this.setOwnerUserRecordID(null);
    this.setGroupType(null);
    this.setGroupName(null);
    this.setGroupDesc(null);
    this.setRecordStatus(null);
    this.setUpdateCount(null);
    this.setCreatorID(null);
    this.setCreateDate(null);
    this.setUpdaterID(null);
    this.setUpdateDate(null);
    this.setUserRoles(null);
  }

  public AbstractBaseObject getFormData() throws ApplicationException {
    UserGroup tmpUserGroup = new UserGroup();
    tmpUserGroup.setID(TextUtility.parseIntegerObj(this.getID()));
    tmpUserGroup.setOwnerUserRecordID(TextUtility.parseIntegerObj(this.getOwnerUserRecordID()));
    tmpUserGroup.setGroupType(this.getGroupType());
    tmpUserGroup.setGroupName(this.getGroupName());
    tmpUserGroup.setGroupDesc(this.getGroupDesc());
    tmpUserGroup.setRecordStatus(this.getRecordStatus());
    tmpUserGroup.setUpdateCount(TextUtility.parseIntegerObj(this.getUpdateCount()));
    tmpUserGroup.setCreatorID(TextUtility.parseIntegerObj(this.getCreatorID()));
    tmpUserGroup.setCreateDate(parseTimestamp(this.getCreateDate()));
    tmpUserGroup.setUpdaterID(TextUtility.parseIntegerObj(this.getUpdaterID()));
    tmpUserGroup.setUpdateDate(parseTimestamp(this.getUpdateDate()));
    return tmpUserGroup;
  }

  public void setFormData(AbstractBaseObject baseObj) throws ApplicationException {
    UserGroup tmpUserGroup = (UserGroup)baseObj;
    this.setID(TextUtility.formatIntegerObj(tmpUserGroup.getID()));
    this.setOwnerUserRecordID(TextUtility.formatIntegerObj(tmpUserGroup.getOwnerUserRecordID()));
    this.setGroupType(tmpUserGroup.getGroupType());
    this.setGroupName(tmpUserGroup.getGroupName());
    this.setGroupDesc(tmpUserGroup.getGroupDesc());
    this.setRecordStatus(tmpUserGroup.getRecordStatus());
    this.setUpdateCount(TextUtility.formatIntegerObj(tmpUserGroup.getUpdateCount()));
    this.setCreatorID(TextUtility.formatIntegerObj(tmpUserGroup.getCreatorID()));
    this.setCreateDate(formatTimestamp(tmpUserGroup.getCreateDate()));
    this.setUpdaterID(TextUtility.formatIntegerObj(tmpUserGroup.getUpdaterID()));
    this.setUpdateDate(formatTimestamp(tmpUserGroup.getUpdateDate()));
  }
}
